<template>
	<view class="content">
		<view class="feed-box">
			<view class="title">请描述您的问题</view>
			<textarea v-model="question" placeholder="请填写问题描述以便我们提供更好的帮助..." name="" id="" cols="30" rows="10"></textarea>
			<view class="title">请上传图片凭证</view>
			<view class="image" style="margin-bottom: 216rpx;">
				<u-upload  ref="uUpload" width="160rpx" height="160rpx" :action="action" :file-list="fileList" ></u-upload>
			</view>
			<button class="u-reset-button btn-moren" @click="save_feed">提交</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				action:this.$IMG_URL+'/index/ajax/upload',
				question:'',
				fileList: []
			}
		},
		methods: {
			//意见反馈提交 /index/save_feed
			save_feed(){
				let files = [];
				let images = []
				// 通过filter，筛选出上传进度为100的文件(因为某些上传失败的文件，进度值不为100，这个是可选的操作)
				files = this.$refs.uUpload.lists.filter(val => {
					return val.progress == 100;
				})
				// 如果您不需要进行太多的处理，直接如下即可
				// files = this.$refs.uUpload.lists;
				console.log(files)
				files.forEach(item =>{
					images.push(item.response.data.url)
				})
				this.$u.post('/index/save_feed',{
					question:this.question,
					images:images.join(',')
				}).then(res =>{
					uni.showToast({
						icon:'success',
						title:res.msg
					})
					setTimeout(()=>{
						uni.navigateBack({
							delta:1
						})
					},800)
				})
			}
		}
	}
</script>

<style lang="less">
	.btn-moren{
		height: 100rpx;
		font-size: 50rpx;
	}
	.content{
		height: 100vh;
	}
.feed-box{
	background: #fff;
	border-radius: 20rpx;
	height: 100%;
	padding: 30rpx 20rpx;
}
.title{
	font-size: 40rpx;
	font-weight: bold;
	margin-bottom: 30rpx;
}
textarea{
	width: 100%;
	height: 400rpx;
	border: 1px solid #F2F2F2;
	padding: 20rpx;
	box-sizing: border-box;
	margin-bottom: 40rpx;
	border-radius: 10rpx;
}
</style>
